#! /usr/bin/env python3
# -*- coding: utf-8 -*-

import param_cache
import time
import logging
logging.basicConfig(level=logging.DEBUG)


class UnitObject(object):

    def process(self, paramc: param_cache.ParamCache):
        logging.info(self.__class__)
        logging.info("--------------start------------------")
        ret = self.process1(paramc)
        if isinstance(ret, param_cache.ParamCache):
            paramc = ret
        time.sleep(0.5)
        logging.info(self.__class__)
        logging.info("--------------finish------------------")
        # paramc = paramc.push_config()
        return paramc

    def process1(self, paramc: param_cache.ParamCache):
        pass


class UnitContext(object):
    def __init__(self, unit: UnitObject):
        self.unit = unit

    def process(self, paramc: param_cache.ParamCache):
        return self.unit.process(paramc)


if __name__ == '__main__':
    dict1 = {'01cmd': 13, '03ctyas': 18, '02yyuas': 45}
    logging.info(dict1)
    list1 = sorted(dict1.items(), key=lambda x:x[0])
    logging.info(list1)
    for param in list1:
        logging.info(param[1])
